/**
 * 
 */
package com.contact.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.contact.model.Message;

/**
 * @author david
 *
 */
public class MessageDaoImpl extends HibernateDaoSupport implements MessageDao {

	/* (non-Javadoc)
	 * @see com.contact.dao.MessageDao#insertMessage()
	 */
	@Override
	public void insertMessage(Message msg) {
		getSession().save(msg);
		
	}

	/* (non-Javadoc)
	 * @see com.contact.dao.MessageDao#loadMessages()
	 */
	@Override
	public List<Message> loadMessages() {
		Query query = getSession().createQuery("from Message m order by m.createDate desc");		
		List<Message> list = (List<Message>)query.list();
		
		return list;		
	}
	
	

}
